/**
 * created by 小卷毛, 2019/7/22
 * Copyright (c) 2019, 416143467@qq.com All Rights Reserved.
 * #                   *********                            #
 * #                  ************                          #
 * #                  *************                         #
 * #                 **  ***********                        #
 * #                ***  ****** *****                       #
 * #                *** *******   ****                      #
 * #               ***  ********** ****                     #
 * #              ****  *********** ****                    #
 * #            *****   ***********  *****                  #
 * #           ******   *** ********   *****                #
 * #           *****   ***   ********   ******              #
 * #          ******   ***  ***********   ******            #
 * #         ******   **** **************  ******           #
 * #        *******  ********************* *******          #
 * #        *******  ******************************         #
 * #       *******  ****** ***************** *******        #
 * #       *******  ****** ****** *********   ******        #
 * #       *******    **  ******   ******     ******        #
 * #       *******        ******    *****     *****         #
 * #        ******        *****     *****     ****          #
 * #         *****        ****      *****     ***           #
 * #          *****       ***        ***      *             #
 * #            **       ****        ****                   #
 */
package com.af.community.smart.event

import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 * 监听生命周期需添加依赖 lifecycle-common-java8
 */
open class BaseViewEvent : DefaultLifecycleObserver, IBaseViewEvent, ViewModel() {

    val baseActionEvent = MutableLiveData<BaseEvent>()

    override fun showLoading(msg: String) {
        val event = BaseEvent(BaseEvent.SHOW_LOADING)
        event.message = msg
        baseActionEvent.value = event
    }

    override fun dismissLoading() {
        val event = BaseEvent(BaseEvent.DISMISS_LOADING)
        baseActionEvent.value = event
    }

    override fun showToast(msg: String) {
        val event = BaseEvent(BaseEvent.TOAST)
        event.message = msg
        baseActionEvent.value = event
    }

    override fun finishView() {
        val event = BaseEvent(BaseEvent.FINISH)
        baseActionEvent.value = event
    }

}